"""
通用辅助函数
"""
import os
import random
import string
from typing import Any, Dict, List, Optional


def generate_random_string(length: int = 8) -> str:
    """
    生成随机字符串
    """
    return "".join(random.choices(string.ascii_letters + string.digits, k=length))


def get_env_variable(key: str, default: Optional[str] = None) -> Optional[str]:
    """
    获取环境变量
    """
    return os.getenv(key, default)


def merge_dicts(dict1: Dict[Any, Any], dict2: Dict[Any, Any]) -> Dict[Any, Any]:
    """
    合并两个字典
    """
    return {**dict1, **dict2}